<?php
/**
 * 案例添加管理页面
 * author:wang
 * mail:970633164@qq.com
 */
define("PHP_IN", true);
require "../include/init.php";
require "checklogin.php";
require ROOT_PATH."cms/smart_connection.php";

if (isset($_POST['dosubmit'])) {
    $title = $_POST['title'];
    $url = $_POST['url'];
    $isdisplay = $_POST['isdisplay'];
    $t = time();
    $srcname = "";
    if ($_FILES['photo']['error'] == 0) {
        $filename = file_ext($_FILES['photo']['name']);
        $srcname = $t.rand(1,10000).$filename;
        $path = $slide_src_up.$srcname;
        $upload = move_uploaded_file($_FILES['photo']['tmp_name'],$path);

    }
    if($title=="" || $url=="" || $srcname==""){
        alert("请填写完整的内容！");
    }

    $sql ="INSERT INTO slidead (name,src,url,addtime,isdisplay) VALUES
          ('$title','$srcname','$url','$t','$isdisplay')";
    $result = $db->query($sql);
    if($result){
        alert("添加成功","slide_list.php");
    }else{
        alert("添加失败");
    }

}
$smarty->display("slide_add.tpl");
$db->close();
?>
